import Opt from '@/components/dt/info/Opt.js'
import organizationOpt from '@/biz/option/organization.js'
import toolMgr from '@/biz/base/tool.js'
import houseOpt from '@/biz/option/house.js'
let _this = null
class SearchOpt extends Opt {
  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [
      // organizationOpt.create({
      //   key: 'orgId',
      //   title: '组织筛选',
      //   placeholder: '请选择',
      //   level: 1,
      //   change: (v) => {
      //     console.log(v.value, 'bbb')
      //     _this.serchChange(v.value)
      //   }
      // }),
      //   {
      //     key: 'orgId',
      //     title: '组织筛选',
      //     select: {
      //       options: []
      //     },
      //     load: (o) => {
      //       toolMgr.organization(1).then((res) => {
      //         res.forEach((item) => {
      //           item.key = String(item.id)
      //           item.value = item.label
      //         })
      //         o.select.options = res
      //       })
      //     }
      //   },
      {
        title: '评级年月',
        placeholder: '全部',
        key: 'mth',

        date: {
          type: 'month',
          clearable: false,
          disabled: (date) => {
            const currentDate = new Date()
            const startOfCurrentMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1)
            const startOfCurrentMonth1 = new Date(2023, 6, 1)
            return date >= startOfCurrentMonth || date < startOfCurrentMonth1
          }
        },
        change: (val) => {
          _this.timeChange()
        }
      },

      {
        title: '所属案场',
        placeholder: '请输入案场名称',
        key: 'houseName',

        input: {
          clearable: true
        }
      }
      // houseOpt.create({
      //   to: (info) => {
      //     return {
      //       buildingId: info.housesId
      //     }
      //   }
      // })
    ]
  }
}

export default SearchOpt
